package main

import (
	"api_gateway/consul"
	"api_gateway/router"
	"github.com/gin-gonic/gin"
)

func main() {
	CounsulInit()

	r := gin.Default()

	router.Router(r)

	r.Run() // 监听并在 0.0.0.0:8080 上启动服务
}

func CounsulInit() {
	config, err := consul.ConuslConfig("14.103.138.43", 8500)
	if err != nil {
		panic(err)
	}

	reg := consul.Register{
		ID:      "yk",
		Name:    "yk",
		Tags:    []string{"yk"},
		Port:    8501,
		Address: "localhost",
	}

	err = config.ConsulRegister(&reg)
	if err != nil {
		return
	}

}
